/*    
    OpenMheg - A free MHEG-5 library
    Copyright (C) 2008 Dharmesh Malam

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using WinForms.Renderer.GDI;
using Core.Model.Ingredients.Presentable.Visibles;
using Bitmap=System.Drawing.Bitmap;
using Rectangle=System.Drawing.Rectangle;

namespace WinForms.Renderer
{
    public class MHEGScreen
    {
        private IMHEGRenderer renderer;

        public IMHEGRenderer Renderer
        {
            get { return renderer; }
            set { renderer = value; }
        }

        private MHEGRenderMode renderMode;

        public MHEGScreen ( MHEGRenderMode mode )
        {
            renderMode = mode;

            if ( mode == MHEGRenderMode.GDIPlusBitmap )
                renderer = new BitmapRenderer();
            else if ( mode == MHEGRenderMode.GDIPlus )
                renderer = new GDIRenderer();
        }

        public void Redraw ()
        {
            Renderer.Redraw( DisplayControl.Instance.DisplayStack );

        }

        public Control Panel
        {
            get { return ((GDIRenderer) Renderer).Panel; }
        }

        //internal void Refresh ( Rectangle [] rs )
        //{
        //    List<Core.Visible> vs = Display.Instance.DisplayStack;
            
        //    //given rs and vs need to compact drawing requests

        //    Renderer.Refresh( rs , vs);
        //}

        internal Bitmap Refresh ( Rectangle [] rs ,List<Visible> vs,Bitmap bitmap)
        {
              //given rs and vs need to compact drawing requests

            return Renderer.DRefresh( rs, vs,bitmap );
        }

        private List<Visible> Compact ( List<Visible> vs )
        {
            foreach ( Visible v in vs.ToArray() )
            {
                
            }

            return vs;
        }

        internal void Clear (Bitmap bitmap)
        {
            renderer.Clear(bitmap);
        }

        internal void Clear ( )
        {
            renderer.Clear( );
        }

        internal void Resize ( Size size )
        {
            renderer.Resize( size );
        }
    }
}